<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	  <jsp:include page="../js_top.jsp"/>
	  <link href="<%=basePath%>/static/css/css.css" rel="stylesheet" type="text/css" />
	<style type="text/css">
		/* 分页ul中的li样式 */
		.pagination ul{margin:2px 10px 0;list-style:none; /* 去掉ul前面的符号 */}
		.pagination ul li{float:left; /* 向左漂移，将竖排变为横排 */}
		.pagination ul>li>a,.pager>li>a{background:none;color:#63666d;padding:4px 8px;font-family:Arial,Verdana,"微软雅黑";font-size:14px;cursor:pointer;}
		.pagination ul>li>a:hover{background:none;}
		.pagination ul>li>a:hover,.pager>li>a:hover{color:#0fb1d6;text-decoration:underline;}
		.pagination ul input{height:23px;margin-top:1.5px;}


		.tab{width:auto;height:26px;float:right;margin:7px 13px 0 0;}
		.tab a{width:24px;height:24px;line-height:24px;text-align:center;display:block;float:left;background:#eff3f5;border:1px solid #9fa3a8;border-radius:5px;color:#727a85;font-size:14px;font-family:Arial,Verdana;font-weight:700;cursor:pointer;}
		.tab a.active,.mms_vip_tab a:hover{color:#fff;border:1px solid #596066;}
		.tab a:not (:last-child ){margin:0 13px 0 0;}
		.tab a:first-child{background:url(/static/img/images/mms_vip_icon.png) no-repeat;}
		.tab a:first-child:hover{background:#727a85 url(/static/img/images/mms_vip_icon1.png) no-repeat;}
		.tab a:nth-child(2){background:url(/static/img/images/mms_vip_icon.png) no-repeat 0px -24px;}
		.tab a:nth-child(2):hover{background:#727a85 url(/static/img/images/mms_vip_icon1.png) no-repeat 0px -24px;}
		.tab a:nth-child(3){background:url(/static/img/images/mms_vip_icon.png) no-repeat 0px -48px;}
		.tab a:nth-child(3):hover{background:#727a85 url(/static/img/images/mms_vip_icon1.png) no-repeat 0px -48px;}
		.tab a:nth-child(4){background:url(/static/img/images/user_roles.png) no-repeat 0px 0px;}
		.tab a::nth-child(4):hover{background:#727a85 url(/static/img/images/user_roles.png) no-repeat 0px -24px;}
		.tab a:nth-child(5){background:url(/static/img/images/Inpassword.png) no-repeat 0px 0px;}
		.tab a:nth-child(5):hover{background:#727a85 url(/static/img/images/Inpassword.png) no-repeat 0px -24px;}
		.tab a:last-child{background:url(/static/img/images/Issued_modify.png) no-repeat 0px 0px;}
		.tab a:last-child:hover{background:#727a85 url(/static/img/images/Issued_modify.png) no-repeat 0px -24px;}
		.tab a:not(:last-child){margin:0 13px 0 0;}


	</style>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="userList">
	<title>用户列表</title>
  </head>
  <body>


  <div class="container-fluid">
	  <div class="row-fluid">
		  <div class="span12">
			<br>
			<!-- 检索  -->
			<form action="sys/sysUser/pageList.do" method="post" name="form1" id="form1" >
				<div style="float: left;">
				<div class="alarm_set_tab" style="margin-top: 10px">
					<span>账号</span>
					<input type="text" id="loginName" name="loginName" value="${sysUser.loginName}" style="width:130px" placeholder="请输入登陆名..." >
					<span style="margin-left: 10px">姓名</span>
					<input type="text" id="userName" name="userName" value="${sysUser.userName}" style="width:130px" placeholder="请输入姓名..." >
					<a href="javascript:search();" style="margin-left: 10px;">查询</a>
				</div>
				</div>
				<div style="float: left;">
				<div style="font-size: 18px;font-family: 微软雅黑, 宋体, 黑体;background:url(<%=basePath%>/static/img/images/right_main_tab1.png) repeat-x center bottom;width:100%;height:51px;border-radius: 5px 5px 0px 0px;border:1px solid #c4cdd8;border-bottom:0px solid #FFFFFF;">
					<span style="line-height:51px; margin-left:15px;">系统用户</span>
						<div style="margin-top:10px;float:right;" class="tab">
							<a title="新增" href="javascript:add();"></a>
							<a title="删除" href="javascript:del();"></a>
                            <a title="编辑" href="javascript:update();"></a>
							<a title="用户角色" href="javascript:editRoles();"></a>
							<a title="初始化密码" href="javascript:initialize();"></a>
							<a title="导出" href="javascript:exportUser();"></a>
						</div>
				</div>
				<div style="width:100%; border:1px solid #c4cdd8">
					<table  class="table table-bordered table-striped table-hover" style="margin-left: 10px;margin-top: 10px; width: 960px">
						<thead>
							<tr>
								<th>登陆名</th>
								<th>姓名</th>
								<th>性别</th>
								<th>年龄</th>
								<th>电话</th>
								<th>备注</th>
							</tr>
						</thead>
						<tbody>
							<c:choose>
								<c:when test="${not empty page.result}">
									<c:forEach items="${page.result}" var="sysUser" varStatus="vs">
										<tr id="tr${vs.count}"  onclick="trOnclick('tr${vs.count}','${sysUser.userId}','${sysUser.loginName}');" >
											<td>${sysUser.loginName}</td>
											<td>${sysUser.userName}</td>
											<td>${sysUser.sex}</td>
											<td>${sysUser.age}</td>
											<td>${sysUser.phone}</td>
											<td>${sysUser.remark}</td>
										</tr>
									</c:forEach>
								</c:when>
								<c:when test="${empty page.result}">   
											<tr>
												<td colspan="9" style="color: red;">暂无数据!</td>
											</tr>
								</c:when>
							</c:choose>
						</tbody>
					</table>

					<div class="pagination" style="float: right; padding-top: 0px; margin-top: 5px;height: 34px;">
						${page.pageStrLess}
					</div>


				</div>
					</div>
			</form>			
		</div>

	</div>
  </div>
  </body>
  
  
  
<script type="text/javascript">
//鼠标点过高亮取到相关数据
var tempClassId = "";
var tridClick = "";
var idClick = "";
var nameClick = "";
var userName = "";
var loginName = "";

function trOnclick(tridTemp,idTemp,nameTemp){
	tridClick = tridTemp;
	idClick = idTemp;
	nameClick = nameTemp;
	$("#"+tridTemp).attr('class','info');
	if(tempClassId!="" && tempClassId!=tridTemp){
		$("#"+tempClassId).attr("class","");
	}
	tempClassId = tridTemp;
}

function search(){
	$('#form1').submit();
}
function add(){
	var diag = new top.Dialog();
	diag.Title="新增";
	diag.URL='<%=basePath%>sys/sysUser/turn.do';//跳转页面函数
	diag.Top="50%";
	diag.Left="30%";
	diag.Width=580;
	diag.Height=230;
	diag.CancelEvent=function(){
        nextPage(${page.currentPage});
		diag.close();
	};
	diag.show();
}
function update(){
	if(idClick ==''){
		layer.msg('请选择数据后再编辑！！');
		return false;
	}
	var diag=new top.Dialog();
	diag.Title="编辑";
	diag.URL='<%=basePath%>sys/sysUser/turn.do?userId='+idClick;
	diag.Top="50%";
	diag.Left="30%";
	diag.Width=580;
	diag.Height=230;
	diag.CancelEvent=function(){
		nextPage(${page.currentPage});
		diag.close();
	};
	diag.show();
}

function del(){
	if(idClick == ''){
		layer.msg('请选择数据后再删除！！');
		return false;
	}
	layer.confirm('确定要删除'+nameClick+'账号吗？',{
		btn:['确定','取消'],
		title:'删除'
	},function(){
		var url = '<%=basePath%>sys/sysUser/delete.do?id='+idClick;
		$.get(url,function(data){
			nextPage(${page.currentPage});
		});
	})

}

//用户角色
function editRoles(){
	if(idClick==""){
		layer.msg('<span style="color:white;font-family:微软雅黑;">请选择记录后再进行操作!</span>');
		return false;
	}
	var  id = idClick;
	var diag = new top.Dialog();
	diag.Drag = true;
	diag.Title = "用户角色";
	diag.URL = '<%=basePath%>sys/sysUser/userRoleEdit.do?id='+id;
	diag.Width = 650;
	diag.Height = 500;
	diag.CancelEvent = function(){ //关闭事件
		diag.close();
	};
	diag.show();
}
function initialize(){
	if(idClick == ''){
		layer.msg('请选择用户后再初始化密码！！');
		return false;
	}
	layer.confirm("你确定要对"+nameClick+"用户进行密码初始化吗？",{
		title:"密码初始化",
		btn:["确定","取消"]
	},function(){
		var url="sys/sysUser/initialize.do";
		var postData={
			"userId":idClick
		};
		$.post(url,postData,function(data){
			if(data == "no"){
				layer.msg("您不是超级管理员，无权进行初始化密码操作！！！",{time:2000});
			}else if(data == "success"){
				layer.msg("初始化密码成功！！！",{time:2000});
			}else if(data == "failure"){
				layer.msg("初始化密码更新失败！！！",{time:2000});
			}else{
				layer.msg("也许是请求失败？",{time:2000});
			}

		});
	})



}
function exportUser(){
	loginName=$('#loginName').val();
	userName=$('#userName').val();
	var url = '<%=basePath%>sys/sysUser/exportUser.do?loginName='+loginName+'&userName='+userName;
	location.href=url;
}
//控制页最小放缩大小
//function changeSize(){
//    var bwidth = document.documentElement.clientWidth;
//    var hmain = document.getElementById("body");
//   // var divmain = document.getElementById("divBody");
//    //var divdata = document.getElementById("data");
//    var alldata = document.getElementById("alldata");
//    hmain.style.width = bwidth+'px';
//    //divmain.style.width = (bwidth-30)+'px';
//    //divdata.style.width = (bwidth-60)+'px';
//    alldata.style.width = (bwidth-60)+'px';
//    //document.getElementById("bbpage").style.width=(bwidth-30)+'px';
//    if($(window).height()-300 > 350){
//        $('#chart').height($(window).height()-300);
//    }else{
//        $('#chart').height(350);
//    }
//}
//changeSize();
//window.onresize=function(){
//    changeSize();
//};

</script>
</html>
